﻿var dbModule = (function () {
    var mongoDB = new MongoLab('FlgTc4pFh1IVFPfxXF2q4qnfBWksx4Sw');

    var Get = Class.create({
        initialize: function () {
            this.count;
        },

        allOffers: function (result) {
            mongoDB.listDocuments('vozime_db', 'drivers', function (data) {
                result(data);
            });
        }
    });

    var Put = Class.create({
        initialize: function (offer) {
            if (offer) {
                mongoDB.insertDocuments('vozime_db', 'drivers', offer);
            }
        }
    });

    return {
        Put : Put,
        Get : Get
    }
})();

//Demo
var car = new TripDetails.Vehicle("кола", "форд", 1995, 5, 9);
var driver = new TripDetails.Driver("Mitio", "Pishtova", "krisiI@abv.bg", "123", 18, "m", car, "10", "no smoking!");
var trip = new TripDetails.Trip("София", "Варна", 320, "12.04.2013");
var price = new TripDetails.Price(3, 'лв.');

var offer = new TripDetails.Offer(driver, price, trip);

//var put = new dbModule.Put(offer);

//var get = new dbModule.Get();

//get.allOffers(function (data) {
//    console.log(data);
//});